package cn.itcast.daoTest;

import cn.itcast.dao.EmployeeMapper;
import cn.itcast.domain.Employee;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/applicationContext-*.xml"})
public class EmployeeTest {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Test
    public void getEmpById() {
        Employee employee = employeeMapper.getEmpById(1);
        System.out.println(employee);
    }

    @Test
    public void insertEmpoyee(){
        Employee employee = new Employee();
        employee.setId(3);
        employee.setEmpName("司澳森");
        employee.setEmail("xxx.@qq.com");
        employee.setGender(1);
        //employeeMapper.insertEmpoyee(employee);

        List<Employee> employeeList = employeeMapper.queryEmployeeAll();
        System.out.println(employeeList);
    }

    @Test
    public void updateEmployeeById(){
        Employee employee = new Employee();
        employee.setId(6);
        employee.setEmpName("李东奎");
        employee.setEmail("17803878933@163.com");
        employee.setGender(1);


        Integer i  = employeeMapper.updateEmployeeById(employee);
        System.out.println(i);
    }
}
